﻿CREATE TABLE [dbo].[PECOSA](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Fecha] [datetime] NOT NULL,
	[Total] [decimal](18, 2) NOT NULL,
	[FechaIngreso] [datetime] NOT NULL,
	[NroDoc] [nvarchar](6) NOT NULL,
	[FechaSalida] [datetime] NULL,
	[IdArea] [int] NOT NULL,
	[IdSolicitante] [int] NOT NULL,
 CONSTRAINT [PK_dbo.PECOSA] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_dbo.PECOSA_dbo.CENTRO_COSTO_IdArea]    Script Date: 11/17/2014 00:41:42 ******/
ALTER TABLE [dbo].[PECOSA]  WITH CHECK ADD  CONSTRAINT [FK_dbo.PECOSA_dbo.CENTRO_COSTO_IdArea] FOREIGN KEY([IdArea])
REFERENCES [dbo].[CENTRO_COSTO] ([ID])
GO

ALTER TABLE [dbo].[PECOSA] CHECK CONSTRAINT [FK_dbo.PECOSA_dbo.CENTRO_COSTO_IdArea]
GO
/****** Object:  ForeignKey [FK_dbo.PECOSA_dbo.TRABAJADOR_IdSolicitante]    Script Date: 11/17/2014 00:41:42 ******/
ALTER TABLE [dbo].[PECOSA]  WITH CHECK ADD  CONSTRAINT [FK_dbo.PECOSA_dbo.TRABAJADOR_IdSolicitante] FOREIGN KEY([IdSolicitante])
REFERENCES [dbo].[TRABAJADOR] ([ID])
GO

ALTER TABLE [dbo].[PECOSA] CHECK CONSTRAINT [FK_dbo.PECOSA_dbo.TRABAJADOR_IdSolicitante]
GO
CREATE NONCLUSTERED INDEX [IX_IdArea] ON [dbo].[PECOSA] 
(
	[IdArea] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_IdSolicitante] ON [dbo].[PECOSA] 
(
	[IdSolicitante] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]